package core.validate.rules;

import core.validate.NumberRule;
import core.validate.RuleTest;

import java.util.List;

public enum NumberType {
    TYPE, COMPARE, MAX, MIN, BETWEEN, NOT_BETWEEN, MULTIPLE,
    GT_WITH, GTE_WITH, LT_WITH, LTE_WITH, EQ_WITH, NEQ_WITH,
    TEST, REGEX, NOT_REGEX, IN, NOT_IN, EMPTY;

    public void apply(NumberRule rule, List<Object> params, String message) {
        switch (this) {
            case TYPE -> rule.type((String) params.get(0), message);
            case COMPARE -> rule.compare((String) params.get(0), (Number) params.get(1), message);
            case MAX -> rule.max((Number) params.get(0), message);
            case MIN -> rule.min((Number) params.get(0), message);
            case BETWEEN -> rule.between((Number) params.get(0), (Number) params.get(1), message);
            case NOT_BETWEEN -> rule.notBetween((Number) params.get(0), (Number) params.get(1), message);
            case MULTIPLE -> rule.multiple((Number) params.get(0), message);
            case GT_WITH -> rule.gtWith((Number) params.get(0), message);
            case GTE_WITH -> rule.gteWith((Number) params.get(0), message);
            case LT_WITH -> rule.ltWith((Number) params.get(0), message);
            case LTE_WITH -> rule.lteWith((Number) params.get(0), message);
            case EQ_WITH -> rule.eqWith((Number) params.get(0), message);
            case NEQ_WITH -> rule.neqWith((Number) params.get(0), message);
            case TEST -> rule.test((RuleTest) params.get(0), message);
            case REGEX -> rule.regex((String) params.get(0), message);
            case NOT_REGEX -> rule.notRegex((String) params.get(0), message);
            case IN -> rule.in((Object[]) params.get(0), message);
            case NOT_IN -> rule.notIn((Object[]) params.get(0), message);
        }
    }
}
